package com.syni.mdd.yhd.common.all.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.syni.mdd.yhd.common.all.constants.Constants;
import com.syni.mdd.yhd.common.all.dto.reponseDto.groupBuy.BusinessRpDto;
import com.syni.mdd.yhd.common.all.dto.reponseDto.groupBuy.GroupContentRpDto;
import lombok.Data;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @className BmsDxGroupBuy
 * @description TOO
 * @Author cfx
 * @DATE 2019/7/24 16:52
 * @VERSION 1.0
 **/
@Entity
@Table(name="bms_dx_group_buy")
@Data
public class BmsDxGroupBuy extends BaseEntity{
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "group_origin_img")
    private String groupOriginImg;

    @Column(name = "group_img")
    private String groupImg;

    @Column(name = "detail_img")
    private String detailImg;

    @Column(name = "detail_width")
    private String detailWidth;

    @Column(name = "detail_height")
    private String detailHeight;

    @Column(name = "business_id")
    private Integer businessId;

    @Column(name = "business_name")
    private String businessName;

    @Column(name = "group_name")
    private String groupName;

    @Column(name = "use_number")
    private String useNumber;

    @Column(name = "group_content")
    private String groupContent;

    @Column(name = "group_value")
    private Double groupValue;

    @Column(name = "group_price")
    private Double groupPrice;

    @Column(name = "cost_price")
    private Double costPrice;

    @Column(name = "use_way")
    private Integer useWay = 1;

    @Column(name = "use_time")
    private String useTime;

    @Column(name = "no_use_date")
    private Integer noUseDate;

    @Column(name = "is_refund_any_time")
    private Integer isRefundAnyTime;

    @Column(name = "is_overdue_refund")
    private Integer isOverdueRefund;

    @Column(name = "is_free_package")
    private Integer isFreePackage;

    @Column(name = "is_use_the_room")
    private Integer isUseTheRoom;

    @Column(name = "is_enjoy_other_ben")
    private Integer isEnjoyOtherBen;

    @Column(name = "need_appointment")
    private Integer needAppointment;

    @Column(name = "limit_buy_num")
    private Integer limitBuyNum;

    @Column(name = "limit_once_buy_num")
    private Integer limitOnceBuyNum;

    @Column(name = "limit_once_use")
    private Integer limitOnceUse;

    @Column(name = "other_services")
    private String ortherServices;

    @Column(name = "expire_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date expireTime;

    @Column(name = "expire_month")
    private String expireMonth;

    @Column(name = "limit_sell_num")
    private Integer limitSellNum;

    /**库存量**/
    @Column(name = "sell_inventory")
    private Integer sellInventory;

    @Column(name = "sell_num")
    private Integer sellNum = 0;

    @Column(name = "finish_num")
    private Integer finishNum = 0;

    @Column(name = "refund_num")
    private Integer refundNum = 0;

    @Column(name = "views_num")
    private Integer viewsNum = 0;

    @Column(name = "bargain_num")
    private Integer bargainNum = 0;

    @Column(name = "status")
    private Integer status = Constants.DRAFT_BOX_STATUS;

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Column(name = "audit_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date auditTime;

    @Column(name = "online_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date onlineTime;

    @Column(name = "offline_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date offlineTime;

    @Column(name = "from_origin")
    private Integer fromOrigin;

    @Column(name = "group_template_id")
    private Integer groupTemplateId = 1;

    @Column(name = "is_exclusive")
    private Integer isExclusive = 0;

    @Column(name = "is_time_limit")
    private Integer isTimeLimit = 0;

    @Column(name = "start_sell_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startSellTime;

    @Column(name = "limit_buy_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date limitBuyTime;

    @Column(name = "use_start_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date useStartTime;

    @Column(name = "use_end_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date useEndTime;

    @Column(name = "discount")
    private String discount;

    @Column(name = "discount_num")
    private Double discountNum;

    @Column(name = "group_type")
    private Integer groupType = 0;

    @Column(name = "is_use_one")
    private Integer isUseOne = 0;

    @Column(name = "is_lady_use")
    private Integer isLadyUse = 0;

    @Column(name = "remark")
    private String remark;

    @Column(name = "limit_single_experience")
    private Integer limitSingleExperience = 0;

    @Column(name = "group_photos")
    private String groupPhotos;

    @Column(name = "group_photos_small")
    private String groupPhotosSmall;

    @Column(name = "cloud_file_url")
    private String cloudFileUrl;

    @Column(name = "cloud_cover_url")
    private String cloudCoverUrl;

    @Transient
    private BusinessRpDto bmsBusiness;

    @Column(name = "bargainId")
    private String bargainId;

    @Transient
    List<GroupContentRpDto> groupContentRpDto;

    @Column(name = "has_gif")
    private Integer hasGif = 0;

    @Column(name = "group_gif")
    private String groupGif;

    @Column(name = "group_html")
    private String groupHtml;

    @Column(name = "is_real_time_account")
    private Integer isRealTimeAccount = 1;

    @Column(name = "group_details")
    private String groupDetails;

    @JsonIgnore
    @Transient
    private List<String> groupDetailArray = new ArrayList<>();

    @Column(name = "least_buy_num")
    private Integer leastBuyNum;

    @Column(name = "is_open_text")
    private Integer isOpenText;

    @Column(name = "text_content")
    private String textContent;

    @Column(name = "is_business_consume")
    private Integer isBusinessConsume;

    /**
     * 跨级佣金
     */
    @Column(name = "is_share_group")
    private Integer isShareGroup;

    /**
     * 跨级佣金
     */
    @Column(name = "across_commision")
    private Double acrossCommision;

    /**
     * 非跨级佣金
     */
    @Column(name = "commision")
    private Double commision;

    //限时时间  天 时 分
    @Transient
    private String robLeftDay = "00";
    @Transient
    private String robLeftHour = "00";
    @Transient
    private String robLeftMinute = "00";

    @Transient
    private String groupPhotos2;
    @Transient
    private String groupPhotosSmall2;

    //用于展示给前端正确的模板id
    @Transient
    @JsonIgnore
    private Integer showTemplateId;
}
